<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><html lang="en">
<HEAD>

<meta name="copyright" content="Copyright (c) IBM Corporation and others 2000, 2005. This page is made available under license. For full details see the LEGAL in the documentation book that contains this page." >

<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=ISO-8859-1">
<META HTTP-EQUIV="Content-Style-Type" CONTENT="text/css">

<LINK REL="STYLESHEET" HREF="../book.css" CHARSET="ISO-8859-1" TYPE="text/css">
<TITLE>
Contexts and key bindings
</TITLE>

<link rel="stylesheet" type="text/css" HREF="../book.css">
</HEAD>
<BODY BGCOLOR="#ffffff">
<h3>Contexts and key bindings</h3>

<p>A <b> context</b> can be specified for a key binding so that the binding is only available when the user is
working within a specific context.  Contexts are declared in the
<b><a href="../reference/extension-points/org_eclipse_ui_contexts.html">org.eclipse.ui.contexts</a></b>
extension point.</p>

<p>A context can be bound to a key binding by specifying the id of the context when the key binding is defined.
For example, if we only wanted the save command to work while the user is editing text, we could specify
a context for the key binding:
</p>
<pre>&lt;extension
         point="org.eclipse.ui.bindings"&gt;
  &lt;key
      sequence=&quot;Ctrl+S&quot;
      commandId=&quot;org.eclipse.ui.file.save&quot;
      <b>contextId="org.eclipse.ui.textEditorScope"</b>
      schemeId=&quot;org.eclipse.ui.defaultAcceleratorConfiguration&quot;&gt;
  &lt;/key&gt;
&lt;/extension&gt;
...
</pre>
(See <a href="workbench_advext_contexts.htm">Contexts</a>) for a more detailed discussion
of contexts and how they are defined.

</BODY>
</HTML>
